TOP Contributors

  1. MIKROE (2654 codes)
  2. Alcides Ramos (352 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136746 times)
  2. FAT32 Library (69953 times)
  3. Network Ethernet Library (55942 times)
  4. USB Device Library (46267 times)
  5. Network WiFi Library (41887 times)
  6. FT800 Library (41174 times)
  7. GSM click (28986 times)
  8. PID Library (26414 times)
  9. mikroSDK (26363 times)
  10. microSD click (25377 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

I2C 1-Wire click

Rating:

5

Author: MIKROE

Last Updated: 2019-05-29

Package Version: 1.0.0.1

mikroSDK Library: 1.0.0.0

Category: 1-Wire

Downloaded: 5401 times

Followed by: 2 users

License: MIT license  

This example shows ID numbers from Unique ID Click and several Thermo Sensors (DS1820), connected on each channel. If there is no device detected on the channel, warning note is shown on TFT.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "I2C 1-Wire click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "I2C 1-Wire click" changes.

Do you want to report abuse regarding "I2C 1-Wire click".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

I2C 1-Wire click

I2C 1-Wire click

Front and back view of I2C 1-Wire Click Board designed in mikroBUS form factor.

View full image

Library Description

The library covers all the necessary functions to control I2C OneWire click board. 
Library performs the communication with the device via I2C protocol by writing to registers and by reading from registers.

Key functions:

  • uint8_t i2conewire_setChannel( uint8_t channel ) - Set the channel function.
  • void i2conewire_writeByteOneWire( uint8_t writeData ) - Generic One Wire writes the byte of data function.
  • uint8_t i2conewire_readByteOneWire() - Generic One Wire read the byte of data function.

Examples description

The application is composed of the three sections :

  • System Initialization - Initializes I2C structures and start to write log.
  • Application Initialization - Initialization driver enables - I2C, also write log.
  • Application Task - This is an example which demonstrates the use of I2C OneWire click board. I2C OneWire click communicates with register via I2C protocol by the write to register and read from the register. This example shows ID numbers for any click with OneWire protocol connected on each channel. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB uart changes for every 1 sec.
void applicationTask()
{
    stateOfCh = 1;
    i2conewire_softReset();
    Delay_10ms();

    i2conewire_setConfig( _I2CONEWIRE_CONFIG_1WS_HIGH | _I2CONEWIRE_CONFIG_SPU_HIGH | _I2CONEWIRE_CONFIG_APU_LOW );
    Delay_10ms();

    for( cntCh = 0; cntCh < 8; cntCh++ )
    {
        i2conewire_setChannel( cntCh );
        i2conewire_oneWireReset();
        Delay_10ms();

        i2conewire_writeByteOneWire( _I2CONEWIRE_WIRE_COMMAND_READ_ROM );
        Delay_10ms();

        for ( cntVal = 8; cntVal > 0; cntVal-- )
        {
            idCode[ cntVal ] = i2conewire_readByteOneWire();

            if( idCode[ cntVal ] == _I2CONEWIRE_WIRE_RESULT_OK )
            {
                ByteToStr( cntCh, logText );
                ltrim( logText );
                mikrobus_logWrite( " Channel ", _LOG_TEXT );
                mikrobus_logWrite( logText, _LOG_TEXT );
                mikrobus_logWrite( " : No device on the channel! ", _LOG_TEXT );
                Delay_100ms();
                break;
            }
            else if ( stateOfCh )
            {
                ByteToStr( cntCh, logText );
                ltrim( logText );
                mikrobus_logWrite( " Channel ", _LOG_TEXT );
                mikrobus_logWrite( logText, _LOG_TEXT );
                mikrobus_logWrite( " : ID = 0x", _LOG_TEXT );
                stateOfCh = 0;
            }

            ByteToHex( idCode[ cntVal ], logText );
            ltrim( logText );
            mikrobus_logWrite( logText, _LOG_TEXT );
            Delay_100ms();
        }

        mikrobus_logWrite( " ", _LOG_LINE );
        mikrobus_logWrite( "---------------------------------------", _LOG_LINE );
   }
}

Other mikroE Libraries used in the example:

  • I2C
  • UART
  • Conversions

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.

ALSO FROM THIS AUTHOR

Altitude click

0

Altitude click features a MEMS pressure sensor MPL3115A2, which provides accurate pressure/altitude (20-bit) and temperature (12-bit) data.

[Learn More]

LED Driver 12 click

0

LED Driver 12 Click is a compact add-on board that simplifies the control of multiple LEDs. This board features the PCA9532, a 16-bit I2C-configurable I/O expander optimized for dimming LEDs in 256 discrete Red/Green/Blue (RGB) steps from NXP Semiconductors. The PCA9532 offers high efficiency, supporting up to 16 LED channels and delivering a maximum of up to 25mA of LED current per channel. It contains an internal oscillator with two user-programmable blink rates and duty cycles coupled to the output PWM. Any bits not used for controlling the LEDs can be used for GPIO expansion, which provides a simple solution when additional I/O is needed for some sensors, push-buttons, or alarm monitoring. This Click board™ is suitable for color mixing and backlight application for amusement products, LED status signalization, home automation projects, and many more.

[Learn More]

Thermo 18 click

0

Thermo 18 Click is a compact add-on board that provides an accurate temperature measurement. This board features the WSEN-TIDS, a silicon-based, high-precision digital temperature sensor with embedded analog and digital signal processing unit from Würth Elektronik.

[Learn More]